//
//  DoctorViewController.m
//  安好
//
//  Created by lianchuang on 14-11-13.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "DoctorViewController.h"
#import "FKSearchBar.h"
#import "DoctorTableViewCell.h"
#import "DocInfoViewController.h"
#import "RegDoctorDetialInfoViewController.h"
#import "LeftViewCell.h"
//doctoruid 不为0就跳这个页面
#import "DocInfoViewController.h"

#define RGB(r, g, b)    [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f]

@interface DoctorViewController ()
{
    FKSearchBar * illSeachBar;
    NSInteger leftControlRight;
    BOOL change;
    //  控制筛选搜索
    BOOL departmentBool;
}
@property (nonatomic, strong) UIView *maskViews;
@property (nonatomic, strong) UITableView *leftTableView;
@property (nonatomic, strong) UITableView *rightTableView;

// 存放地区
@property (nonatomic, strong) NSMutableArray *rightTableArr;
@property (nonatomic, strong) NSString *seekAddrStr;

// 存放左边的类型 和右侧的等级
@property (nonatomic, strong) NSArray *leftDataType;
@property (nonatomic, strong) NSArray *levelArr;
@property (nonatomic, strong) NSString *dengJiStr;

//  职务
@property (nonatomic, strong) NSArray *positionArr;
@property (nonatomic, strong) NSString *positionStr;
@property (nonatomic, strong) NSArray *doclevilid;
@property (nonatomic, strong) NSString *docleviStr;

//  记录当前的cell
@property (nonatomic, strong) UITableViewCell *rightTableCell;
@property (nonatomic, strong) LeftViewCell *leftTableCell;
// 存放第一次加载时默认的cell(只执行一次)
@property (nonatomic, strong) NSMutableArray *indexArr;
@property (nonatomic, strong) NSString *dengjiNum;
@property (nonatomic, strong) NSArray *dengjiNumArr;

// 存放地区和类型
@property (nonatomic, strong) NSString *cityid;
@property (nonatomic, strong) NSString *provinceid;

// 控制线条的
@property (nonatomic, strong) UIView *transverseLineView;
@property (nonatomic, strong) UIView *shotVerticalLineView;
@property (nonatomic, strong) UIView *longVerticalLineView;
@end

@implementation DoctorViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.docdorPage = 1;
    [super viewDidLoad];
    self.docdorArray = [[NSMutableArray alloc]init];
    [self makeNavBar];
    [self loadData];
    if (self.isFromMyFoucus) {
    }else{
        [self markIllnessSearchBar];
    }
    [self makeIllnessTableView];
    [self makeTableView];
    leftControlRight = 100;
    change = YES;
    departmentBool = YES;
}
#pragma - mark searchBar
- (void)markIllnessSearchBar
{
    illSeachBar = [[FKSearchBar alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 44)];
    illSeachBar.searchTextField.placeholder = @"医生";
    illSeachBar.fkSearchRequestDelegate = self;
    [self.view addSubview:illSeachBar];
}
-(void)makeNavBar
{
    self.navigationItem.title = @"医生";
    // “返回”
    UIBarButtonItem *backBtnItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBackDown)];
    backBtnItem.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = backBtnItem;
    
    if (self.isFromMyFoucus) {
        
    }else{
        // “筛选”
        UIButton *rightButtonMore = [UIButton buttonWithType:UIButtonTypeCustom];
        rightButtonMore.frame = CGRectMake(0,0, 23, 23);
        [rightButtonMore setImage:[UIImage imageNamed:@"公用_更多.png"] forState:UIControlStateNormal];
        [self makeRightFilterItem];
    }
}

//返回 百科页面
-(void)leftBackDown
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)makeRightFilterItem
{
    UIBarButtonItem *filterBtnItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_筛选.png"] style:UIBarButtonItemStylePlain target:self action:@selector(filterBtnDown)];
    filterBtnItem.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = filterBtnItem;
}
//“完成”
-(void)makeRightFilterFinishItem
{
    UIBarButtonItem *filterBtnItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_完成.png"] style:UIBarButtonItemStylePlain target:self action:@selector(filterFinishDown)];
    filterBtnItem.tintColor = [UIColor whiteColor];
    filterBtnItem.tag = 100;
    self.navigationItem.rightBarButtonItem = filterBtnItem;
}

/**
 *  点击“筛选” 按钮图标换成“完成”
 *   下拉-选项列表 
 */
-(void)filterBtnDown
{
    [self makeRightFilterFinishItem];
    [self loadDataDepartment];
//    [UIView animateWithDuration:0.2 animations:^{
        self.leftTableView.frame = CGRectMake(0, 0, kScreenWidth / 2, 200);
        self.rightTableView.frame = CGRectMake(kScreenWidth / 2, 0, kScreenWidth / 2, 200);
        self.longVerticalLineView.frame = CGRectMake(kScreenWidth / 2 - 0.5, 80 + 35, 0.5, 120 - 35);
//    }];
    [self.view addSubview:self.maskViews];
    [self.view addSubview:self.transverseLineView];
    [self.view addSubview:self.shotVerticalLineView];
    [self.view addSubview:self.longVerticalLineView];
}
/**
 *  点击"完成"图标变回“筛选”
 *  选项列表收回
 */
-(void)filterFinishDown
{
    departmentBool = YES;
    [self.docdorArray removeAllObjects];
    [self makeRightFilterItem];
//    [UIView animateWithDuration:0.2 animations:^{
        self.leftTableView.frame = CGRectMake(0, -200, kScreenWidth / 2, 200);
        self.rightTableView.frame = CGRectMake(kScreenWidth / 2,-200, kScreenWidth / 2, 200);
        self.longVerticalLineView.frame = CGRectMake(kScreenWidth / 2 - 0.5, 80 + 35, 0, 0);
//    }];
    [self.maskViews removeFromSuperview];
    [self.transverseLineView removeFromSuperview];
    [self.shotVerticalLineView removeFromSuperview];
    [self.longVerticalLineView removeFromSuperview];
    self.docdorPage = 1;
    [self loadData];
}

- (void)packUpView{
    [self makeRightFilterItem];
//    [UIView animateWithDuration:0.2 animations:^{
        self.leftTableView.frame = CGRectMake(0, -200, kScreenWidth / 3, 200);
        self.rightTableView.frame = CGRectMake(kScreenWidth/3,-200, kScreenWidth/3 * 2, 200);
//    }];
    [self.maskViews removeFromSuperview];
    [self.transverseLineView removeFromSuperview];
    [self.shotVerticalLineView removeFromSuperview];
    [self.longVerticalLineView removeFromSuperview];
}


#pragma - mark tableView
/**
 *  加载tableView
 */
- (void)makeIllnessTableView
{
    if (self.isFromMyFoucus) {
        self.docdorTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, kScreenWidth, kScreenHeight - iOS7TopMargin) style:UITableViewStylePlain];
    }else{
        self.docdorTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,44, kScreenWidth, kScreenHeight - iOS7TopMargin - 44) style:UITableViewStylePlain];
    }
    self.docdorTableView.delegate = self;
    self.docdorTableView.dataSource = self;
    self.docdorTableView.showsHorizontalScrollIndicator = NO;
    self.docdorTableView.showsVerticalScrollIndicator = NO;
    [self.docdorTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];//去掉系统的分割线
    [self.docdorTableView addFooterWithTarget:self action:@selector(loadData)];
    [self.view addSubview:self.docdorTableView];
}
#pragma mark - 数据加载 -
-(void)loadData
{
    [self showActionView];
    NSString * postURL;
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]initWithCapacity:10];
    if (self.isFromBaike) {
        postURL = [NSString stringWithFormat:@"%@guahao/doctorListByDiseaseid",kBaseURL];
        [dict setObject:self.hosid forKey:@"diseaseid"];
        if (departmentBool){
            if (![self.seekAddrStr isEqualToString:@"全部"]) {
                [dict setValue:self.cityid forKey:@"cityid"];
                [dict setValue:self.provinceid forKey:@"provinceid"];
                [dict setValue:self.dengjiNum forKey:@"hospitallevel"];
                [dict setValue:self.docleviStr forKey:@"doclevelid"];
            }else{
                [dict setValue:self.dengjiNum forKey:@"hospitallevel"];
                [dict setValue:self.docleviStr forKey:@"doclevelid"];
            }
        }else{
            postURL = [NSString stringWithFormat:@"%@guahao/doctorListByDiseaseid/",kBaseURL];
        }
    }else if (self.isFromMyFoucus){
        postURL = [NSString stringWithFormat:@"%@collection/list/",kBaseURL];
        [dict setObject:@"4" forKey:@"type"];
    }else if (departmentBool){
//        [dict removeObjectForKey:@"keyword"];
        postURL = [NSString stringWithFormat:@"%@doctor/",kBaseURL];
        if (![self.seekAddrStr isEqualToString:@"全部"]) {
            [dict setValue:self.cityid forKey:@"cityid"];
            [dict setValue:self.provinceid forKey:@"provinceid"];
            [dict setValue:self.dengjiNum forKey:@"hospitallevel"];
            [dict setValue:self.docleviStr forKey:@"doclevelid"];
        }else{
            [dict setValue:self.dengjiNum forKey:@"hospitallevel"];
            [dict setValue:self.docleviStr forKey:@"doclevelid"];
        }
    }else{
        postURL = [NSString stringWithFormat:@"%@doctor/",kBaseURL];
    }
    
    if ([self.searchdocdor length] == 0){
        
    }else{
        if (self.isFromBaike) {
            [dict setObject:self.searchdocdor forKey:@"q"];
        }else{
        [dict setObject:self.searchdocdor forKey:@"keyword"];
        }
    }
    
    
    [dict setObject:kPlatform forKey:@"platform"];
    [dict setObject:kVersion forKey:@"version"];
    [dict setObject:[NSString stringWithFormat:@"%ld",(long)self.docdorPage] forKey:@"page"];
    MyNSLog("=====%@", dict);
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:postURL parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        [self hiddenActionView];
        if ([statusString isEqualToString:@"0"]) {
            if (self.docdorPage == 1){
                [self shouLabel:@"暂无内容"];
            }
            [self.docdorTableView reloadData];
            [self.docdorTableView footerEndRefreshing];
        }else{
            NSArray *jsonDictArr = [[responseObject objectForKey:@"data"] isEqual:[NSNull null]]?nil:[responseObject objectForKey:@"data"];
            MyNSLog("%@", jsonDictArr);
//            if (self.isSearch == YES){
//                if ([self.docdorArray count] != 0){
//                    [self.docdorArray removeAllObjects];
//                }
//            }
            if (jsonDictArr!=nil) {
                self.docdorPage++;
                for (NSDictionary * dic in jsonDictArr){
                    [self.docdorArray addObject:dic];
                }
                [self.docdorTableView reloadData];
            }else if ([jsonDictArr count] < 20){
                [self.docdorTableView footerEndRefreshing];
            }else{
                if (self.docdorPage>1) {
                    MyNSLog("下拉无数据");
                }
            }
            
        }
        if (self.docdorArray.count != 0) {
            [self shouLabel:@""];
        }
        [self.docdorTableView footerEndRefreshing];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
        [self.docdorTableView footerEndRefreshing];
    }];
    
}
#pragma mark 2中cell的加载

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.leftTableView) {
        return 3;
    }
    if (tableView == self.rightTableView) {
        if (leftControlRight == 100) {
            return self.rightTableArr.count;
        }else if (leftControlRight == 200){
            return self.positionArr.count;
        }else{
            return self.levelArr.count;
        }
    }
    return [self.docdorArray count];
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView == self.leftTableView || tableView == self.rightTableView) {
        return 35;
    }
    if (kScreenWidth == 414){
        return 85;

    }else{
        return 65;
    }
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (tableView == self.leftTableView || tableView == self.rightTableView) {
        return 10;
    }
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (tableView == self.leftTableView || tableView == self.rightTableView) {
        return 5;
    }
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    view.backgroundColor = [UIColor lightGrayColor];
    if (tableView == self.leftTableView) {
        view.backgroundColor = RGB(248, 248, 248);
        return view;
    }
    if (tableView == self.rightTableView) {
        view.backgroundColor = RGB(238, 238, 238);
        return view;
    }
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    view.backgroundColor = [UIColor lightGrayColor];
    if (tableView == self.leftTableView) {
        view.backgroundColor = RGB(248, 248, 248);
        return view;
    }
    if (tableView == self.rightTableView) {
        view.backgroundColor = RGB(238, 238, 238);
        return view;
    }
    return nil;
}


-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (change) {
        self.leftTableCell = (LeftViewCell *)[self.leftTableView cellForRowAtIndexPath:[self.indexArr firstObject]];
    }
    
    if (tableView == self.docdorTableView) {
        NSDictionary * illDic = [self.docdorArray objectAtIndex:indexPath.row];
        DoctorTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DoctorTableViewCell"];
        if (cell == nil) {
            if (kScreenWidth == 414){
                
                cell = [[[NSBundle mainBundle] loadNibNamed:@"DoctorTableViewCell" owner:self options:nil] lastObject];
            }else{
                cell = [[[NSBundle mainBundle] loadNibNamed:@"DoctorTableViewCell" owner:self options:nil] firstObject];

            }
        }
        cell.userLabel.text = [illDic objectForKey:@"doctorname"];
        cell.addressLabel.text = [illDic objectForKey:@"doclevelname"];
        cell.goodLabel.text = [illDic objectForKey:@"feature"];
        
        if ([[illDic objectForKey:@"photo"] integerValue] == 0) {
            [cell.userImageView setImage:[UIImage imageNamed:@"doc-unknow.png"]];
        }else if ([[illDic objectForKey:@"photo"] integerValue] == 1){
            [cell.userImageView setImageWithURL:[NSURL URLWithString:[illDic objectForKey:@"photourl"]]placeholderImage:[UIImage imageNamed:@"doc-unknow.png"]];
        }
        cell.userImageView.layer.cornerRadius=3;
        cell.userImageView.layer.masksToBounds=YES;
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    if (tableView == self.rightTableView) {
        static NSString *indentify = @"rightCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentify];
        }
        
        cell.textLabel.font = [UIFont systemFontOfSize:14];
        cell.backgroundColor = RGB(238, 238, 238);
        if (leftControlRight == 100) {
            if (indexPath.row == 0) {
                cell.textLabel.text = [NSString stringWithFormat:@"全部"];
            }else{
                cell.textLabel.text = [NSString stringWithFormat:@"%@",[self.rightTableArr[indexPath.row - 1] objectForKey:@"name"]];
                MyNSLog("%@", self.rightTableArr );
            }
        }else if (leftControlRight == 200){
            cell.textLabel.text = self.positionArr[indexPath.row];
        }else{
            cell.textLabel.text = self.levelArr[indexPath.row];
        }
        change = NO;
        return cell;
    }
    if (tableView == self.leftTableView) {
        static NSString *indentify = @"leftCell";
        LeftViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];
        if (!cell) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"LeftViewCell" owner:self options:nil] lastObject];
        }
        cell.lineView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#cccccc"];
        if (indexPath.row == 0) {
            cell.backgroundColor = RGB(238, 238, 238);
            [self.indexArr addObject:indexPath];
            cell.lineView.hidden = YES;
        }else{
            cell.backgroundColor = RGB(248, 248, 248);
        }
        cell.typeLabel.text = self.leftDataType[indexPath.row];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (tableView == self.leftTableView) {
        LeftViewCell *leftcell = (LeftViewCell *)[self.leftTableView cellForRowAtIndexPath:indexPath];
        self.leftTableCell.contentView.backgroundColor = RGB(248, 248, 248);
        leftcell.contentView.backgroundColor = RGB(238, 238, 238);
        
        if (indexPath.row == 0) {
            [self.rightTableArr removeAllObjects];
            leftControlRight = 100;
            leftcell.lineView.hidden = YES;
            self.leftTableCell.lineView.hidden = NO;
            [self loadDataDepartment];
        }else if (indexPath.row == 1){
            leftControlRight = 200;
            leftcell.lineView.hidden = YES;
            self.leftTableCell.lineView.hidden = NO;
            [self.rightTableView reloadData];
        }else{
            leftControlRight = 300;
            leftcell.lineView.hidden = YES;
            self.leftTableCell.lineView.hidden = NO;
            [self.rightTableView reloadData];
        }
        
        if ([leftcell isEqual:self.leftTableCell]) {
            leftcell.lineView.hidden = YES;
        }
        self.leftTableCell = (LeftViewCell *)[self.leftTableView cellForRowAtIndexPath:indexPath];
        self.leftTableCell = leftcell;
        return;
    }
    
    if (tableView == self.rightTableView){
        if (leftControlRight == 100) {
            if (indexPath.row == 0) {
                self.seekAddrStr = [NSString stringWithFormat:@"全部"];
            }else{
                self.seekAddrStr = [NSString stringWithFormat:@"%@",[self.rightTableArr[indexPath.row - 1] objectForKey:@"name"]];
                self.cityid = [NSString stringWithFormat:@"%@",[self.rightTableArr[indexPath.row - 1] objectForKey:@"cityid"]];
                self.provinceid = [NSString stringWithFormat:@"%@",[self.rightTableArr[indexPath.row - 1] objectForKey:@"provinceid"]];
                
            }
            self.rightTableCell.contentView.backgroundColor = RGB(238, 238, 238);
            self.leftTableCell.nameLabel.text = self.seekAddrStr;
            
            [self.rightTableView cellForRowAtIndexPath:indexPath].contentView.backgroundColor = RGB(226, 226, 226);;
            self.rightTableCell = [self.rightTableView cellForRowAtIndexPath:indexPath];
        }else if (leftControlRight == 200){
            [self.rightTableArr removeAllObjects];
            self.positionStr = [NSString stringWithFormat:@"%@",self.positionArr[indexPath.row]];
            self.docleviStr = [NSString stringWithFormat:@"%@",self.doclevilid[indexPath.row]];
            self.rightTableCell.contentView.backgroundColor = RGB(238, 238, 238);
            self.leftTableCell.nameLabel.text = self.positionStr;
            MyNSLog("%@", self.positionStr);
            [self.rightTableView cellForRowAtIndexPath:indexPath].contentView.backgroundColor = RGB(226, 226, 226);;
            self.rightTableCell = [self.rightTableView cellForRowAtIndexPath:indexPath];
            
        }else{
            [self.rightTableArr removeAllObjects];
            self.dengJiStr = [NSString stringWithFormat:@"%@",self.levelArr[indexPath.row]];
            self.dengjiNum = [NSString stringWithFormat:@"%@",self.dengjiNumArr[indexPath.row]];
            self.rightTableCell.contentView.backgroundColor = RGB(238, 238, 238);
            self.leftTableCell.nameLabel.text = self.dengJiStr;
            MyNSLog("%@", self.dengJiStr);
            [self.rightTableView cellForRowAtIndexPath:indexPath].contentView.backgroundColor = RGB(226, 226, 226);;
            self.rightTableCell = [self.rightTableView cellForRowAtIndexPath:indexPath];
        }
        return;
    }

    
    
    
    
    NSString * doctoruid = [[self.docdorArray objectAtIndex:indexPath.row] valueForKey:@"doctoruid"];
    if ([doctoruid intValue] ==0 ) {
        RegDoctorDetialInfoViewController *docInfo=[[RegDoctorDetialInfoViewController alloc]init];
        docInfo.doctorid=[[self.docdorArray objectAtIndex:indexPath.row] valueForKey:@"doctorid"];
        [self.navigationController pushViewController:docInfo animated:YES];
    }else
    {
        DocInfoViewController * docUId = [[DocInfoViewController alloc] init];
        docUId.doctoruid = doctoruid;
        [self.navigationController pushViewController:docUId animated:YES];    
    }
    

    
}

#pragma - mark FKSearchDelegate
/**
 *  FKSearch的delegate
 */
- (void)VoiceConversion
{
    [illSeachBar.searchTextField resignFirstResponder];
    [self starVoice];
}
- (void)voice:(NSString *)voice
{
    [self.docdorArray removeAllObjects];
    illSeachBar.searchTextField.text = voice;
    departmentBool = NO;
    self.isSearch = YES;
    self.docdorPage = 1;
    self.searchdocdor = voice;
    [self loadData];
}
- (void)SearchString
{
    [self.docdorArray removeAllObjects];
    [illSeachBar.searchTextField resignFirstResponder];
    departmentBool = NO;
    self.isSearch = YES;
    self.docdorPage = 1;
    self.searchdocdor = illSeachBar.searchTextField.text;
    [self loadData];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - leftTableView和rightTableView的实现 -

-(void)makeTableView
{
    
    self.LeftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, -200, kScreenWidth / 2, 0)];
    self.leftTableView.backgroundColor = RGB(248, 248, 248);
    [self.view addSubview:self.leftTableView];
    self.leftTableView.delegate = self;
    self.leftTableView.dataSource = self;
    //隐藏横向和竖向的滑条
    self.leftTableView.showsHorizontalScrollIndicator = NO;
    self.leftTableView.showsVerticalScrollIndicator = NO;
    self.leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.leftDataType = @[@"地区",@"职称",@"性质"];
    self.positionArr = @[@"全部",@"主任医师",@"副主任医师",@"主治医师",@"医师",@"其他"];
    self.levelArr = @[@"全部",@"三级特等",@"三级甲等",@"三级乙等",@"三级丙等",@"二级甲等",@"二级乙等",@"二级丙等",@"一级甲等",@"一级乙等",@"一级丙等",@"对外专科",@"其他"];
    self.dengjiNumArr = @[@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12"];
    self.doclevilid = @[@"0",@"1",@"2",@"3",@"4",@"5"];
    //左边的table
    self.RightTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth / 2, - 200, kScreenWidth / 2, 0)];
    [self.view addSubview:self.rightTableView];
    self.rightTableView.delegate = self;
    self.rightTableView.dataSource = self;
    //隐藏横向和竖向的滑条
    self.rightTableView.showsHorizontalScrollIndicator = NO;
    self.rightTableView.showsVerticalScrollIndicator = NO;
    self.rightTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.rightTableView.backgroundColor = RGB(238, 238, 238);
    
    
}


#pragma mark - 数据加载
-(void)loadDataDepartment
{
    [self showActionView];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]initWithCapacity:10];
    [dict setObject:kPlatform forKey:@"platform"];
    [dict setObject:kVersion forKey:@"version"];
    [dict setValue:@"2" forKey:@"returnType"];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@wiki/area/",kBaseURL] parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        [self hiddenActionView];
        if ([statusString isEqualToString:@"0"]) {
//            [self shouLabel:@"暂无内容"];
        }else{
            NSArray *jsonDictArr = [[responseObject objectForKey:@"data"] isEqual:[NSNull null]]?nil:[responseObject objectForKey:@"data"];
//            MyNSLog("%@", jsonDictArr);
            for (NSDictionary *objc in jsonDictArr) {
                [self.rightTableArr addObject:objc];
            }
        }
        [self.rightTableView reloadData];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
    }];
    
}


#pragma mark - 懒加载 -
- (UIView *)transverseLineView{
    if (_transverseLineView == nil) {
        _transverseLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 199.5, kScreenWidth, 0.5)];
        _transverseLineView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#cccccc"];
    }
    return _transverseLineView;
}

- (UIView *)shotVerticalLineView{
    if (_shotVerticalLineView == nil) {
        _shotVerticalLineView = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth / 2 - 0.5 , 0, 0.5, 10)];
        _shotVerticalLineView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#cccccc"];
    }
    return _shotVerticalLineView;
}

- (UIView *)longVerticalLineView{
    if (_longVerticalLineView == nil) {
        _longVerticalLineView = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth / 2 - 0.5, 80 + 35, 0.5, 120 - 35)];
        _longVerticalLineView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#cccccc"];
    }
    return _longVerticalLineView;
}


- (NSMutableArray *)rightTableArr{
    if (_rightTableArr == nil) {
        self.rightTableArr = [NSMutableArray array];
    }
    return _rightTableArr;
}


- (NSMutableArray *)indexArr{
    if (_indexArr == nil) {
        self.indexArr = [NSMutableArray array];
    }
    return _indexArr;
}

- (UITableViewCell *)rightTableCell{
    if (_rightTableCell == nil) {
        _rightTableCell = [[UITableViewCell alloc] init];
    }
    return _rightTableCell;
}

- (LeftViewCell *)leftTableCell{
    if (_leftTableCell == nil) {
        _leftTableCell = [[LeftViewCell alloc] init];
    }
    return _leftTableCell;
}

- (NSArray *)dengjiNumArr{
    if (_dengjiNumArr == nil) {
        _dengjiNumArr = [NSArray array];
    }
    return _dengjiNumArr;
}

- (UIView *)maskViews{
    if (_maskViews == nil) {
        _maskViews = [[UIView alloc] initWithFrame:CGRectMake(0, 200, kScreenWidth, kScreenHeight - 264)];
        _maskViews.alpha = 0.5;
        _maskViews.backgroundColor = [UIColor lightGrayColor];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(packUpView)];
        tap.numberOfTapsRequired = 1;
        [_maskViews addGestureRecognizer:tap];
    }
    return _maskViews;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
